﻿//using System;
//using System.Collections;
//using System.Configuration;
//using System.Data;
//using System.Linq;
//using System.Web;
//using System.Web.Security;
//using System.Web.UI;
//using System.Web.UI.HtmlControls;
//using System.Web.UI.WebControls;
//using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;
//using System.Web.Services;
//using System.Collections.Generic;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Web.Services;
public partial class sideBar_right : System.Web.UI.UserControl
{
    VLGDataContext _db1 = new VLGDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            this.loadMenu();           
        }

    }
    void loadMenu()
    {
        var itemMenu = from cate in _db1.Categories
                       where cate.AnHien == true
                       orderby cate.ThuTu
                       select cate;
        rpt_sideBarR.DataSource = itemMenu;
        rpt_sideBarR.DataBind();
        // do Dropdownlist
        dropSearch.DataSource = itemMenu;
        dropSearch.DataTextField = "TenCate";
        dropSearch.DataValueField = "idCategory";
        //dropSearch.SelectedIndex = 1;
        dropSearch.DataBind();
        if (Session["SearchOptValue"] != null)
        {
            dropSearch.SelectedValue = Session["SearchOptValue"].ToString();
        }
        else
        {
            Session["SearchOptValue"] = 1;
        }


    }   

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        string chuoisearch = textSearch.Text.ToString().Trim();
        string optgg = dropSearch.SelectedValue.ToString();
        Session["SearchText"] = chuoisearch;

        string chuoiguidi = "tim-kiem-" + chuoisearch + "-theo-" + Session["SearchOptValue"];

        Response.Redirect(URLHelper.BuildURL(chuoiguidi));
    }

    protected void dropSearch_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["SearchOptValue"] = dropSearch.SelectedValue.ToString();
    }
   
}
